const mongoose = require('mongoose');
require('dotenv').config();

async function checkDatabase() {
  try {
    await mongoose.connect(process.env.MONGODB_URI);
    console.log('Successfully connected to MongoDB');
    
    // 检查挑战集合
    const Challenge = require('../models/Challenge');
    const count = await Challenge.countDocuments();
    console.log(`Found ${count} challenges in database`);
    
    const challenges = await Challenge.find();
    console.log('Challenges:', challenges);
    
    mongoose.connection.close();
  } catch (error) {
    console.error('Database check failed:', error);
  }
}

checkDatabase(); 